import { generateRandomId } from '@/utils';
import { ProductionType } from '@/config';

export const editConfig: PageConfig = {
    labelWidth: 140,
    items: [
        {
            itemType: 'text',
            modelKey: 'materialCode',
            elInputProps: {
                placeholder: '请输入物料编码',
                disabled: true,
                maxlength: '50',
                showWordLimit: true
            },
            columnProps: {
                label: '物料编码'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'text',
            modelKey: 'materialName',
            elInputProps: {
                placeholder: '请输入物料名称',
                maxlength: '50',
                showWordLimit: true
            },
            columnProps: {
                label: '物料名称'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'select',
            slotName: 'materialClassificationSlot',
            modelKey: 'materialClassificationId',
            columnProps: {
                label: '物料分类'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'select',
            modelKey: 'productionType',
            elSelectProps: {
                placeholder: '请选择生产类型',
                options: [
                    {
                        label: ProductionType['HANDMADE'],
                        value: ProductionType['HANDMADE']
                    },
                    {
                        label: ProductionType['OUTSOURCE'],
                        value: ProductionType['OUTSOURCE']
                    },
                    {
                        label: ProductionType['BUYOUT'],
                        value: ProductionType['BUYOUT']
                    }
                ]
            },
            columnProps: {
                label: '生产类型'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'text',
            modelKey: 'materialSpecification',
            elInputProps: {
                placeholder: '请输入物料规格',
                maxlength: '50',
                showWordLimit: true
            },
            columnProps: {
                label: '物料规格'
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            itemType: 'select',
            modelKey: 'manufacturingStrategy',
            elSelectProps: {
                placeholder: '请选择制造策略',
                options: [
                    {
                        label: 'MTO',
                        value: 'MTO'
                    },
                    {
                        label: 'MTS',
                        value: 'MTS'
                    }
                ]
            },
            columnProps: {
                label: '制造策略'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'number',
            modelKey: 'inventory',
            elInputNumberProps: {
                placeholder: '请输入',
                min: 0,
                max: 9999999999.99,
                precision: 2,
                controls: false
            },
            columnProps: {
                label: '库存'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'number',
            modelKey: 'safetyInventory',
            elInputProps: {
                placeholder: '请输入安全库存'
            },
            columnProps: {
                label: '安全库存'
            },
            elInputNumberProps: {
                placeholder: '请输入',
                min: 0,
                max: 9999999999.99,
                precision: 2,
                controls: false
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'number',
            modelKey: 'fixedLeadTime',
            elInputNumberProps: {
                placeholder: '请输入固定提前期',
                min: 1,
                max: 9999999999,
                precision: 0,
                controls: false
            },
            columnProps: {
                label: '固定提前期'
            },
            otherConfig: {
                tip: true,
                tipMsg: '生产类型为外购和委外则该项为必填项'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'number',
            modelKey: 'fixedLeadTimeBatch',
            columnProps: {
                label: '固定提前期批量',
                width: 150
            },
            elInputNumberProps: {
                placeholder: '请输入固定提前期批量',
                min: 1,
                max: 9999999999,
                precision: 0,
                controls: false
            },
            otherConfig: {
                tip: true,
                tipMsg: '生产类型为外购和委外则该项为必填项；外购类型的物料请按照采购单位填写批量；委外类型的物料请按照生产单位填写批量'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            itemType: 'number',
            modelKey: 'finishedProductRate',
            elInputNumberProps: {
                placeholder: '请输入成品率',
                min: 1,
                max: 100,
                precision: 2,
                controls: false
            },
            columnProps: {
                label: '成品率(%)'
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            itemType: 'text',
            modelKey: 'material',
            elInputProps: {
                placeholder: '请输入材质',
                maxlength: '20',
                showWordLimit: true
            },
            columnProps: {
                label: '材质'
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            slotName: 'productUnit',
            modelKey: 'productUnit',
            elInputProps: {
                placeholder: '请输入单位',
                maxlength: '50',
                showWordLimit: true
            },
            columnProps: {
                label: '生产单位'
            },
            validProps: {
                id: generateRandomId(),
                required: true
            }
        },
        {
            slotName: 'purchaseUnit',
            modelKey: 'purchaseUnit',
            elInputProps: {
                placeholder: '请输入单位'
            },
            columnProps: {
                label: '采购单位'
            },
            otherConfig: {
                tip: true,
                tipMsg: '生产类型为外购和委外则该选项为必填项'
            },
            validProps: {
                id: generateRandomId()
            }
        }
    ]
};
